<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改主轴监控')" />
</head>
<body>
<form class="layui-form" th:object="${sysAxis}">
    <div class="mainBox">
        <div class="main-container">
            <input name="axisId" th:field="*{axisId}" type="hidden">
    <div class="layui-form-item">
        <label class="layui-form-label">主轴位置：</label>
        <div class="layui-input-block">
            <input type="text" name="axisSpace" th:field="*{axisSpace}" placeholder="请输入主轴位置" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">主轴图片：</label>
        <div class="layui-input-block">
            <input type="text" name="axisPrc" th:field="*{axisPrc}" placeholder="请输入主轴图片" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">主轴型号：</label>
        <div class="layui-input-block">
            <select name="axisType"  dict-code="input" th:attr="default-value=*{axisType}" >
                <option value="">所有</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">当前操作者：</label>
        <div class="layui-input-block">
            <input type="text" name="currentOperator" th:field="*{currentOperator}" placeholder="请输入当前操作者" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">主轴状态：</label>
        <div class="layui-input-block">
            <input type="text" name="axisState" th:field="*{axisState}" placeholder="请输入主轴状态" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">执行程序：</label>
        <div class="layui-input-block">
            <input type="text" name="executiveRoutine" th:field="*{executiveRoutine}" placeholder="请输入执行程序" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计划加工：</label>
        <div class="layui-input-block">
            <input type="text" name="scheduling" th:field="*{scheduling}" placeholder="请输入计划加工" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">售后公司：</label>
        <div class="layui-input-block">
            <input type="text" name="manufacturer" th:field="*{manufacturer}" placeholder="请输入售后公司" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">售后公司电话：</label>
        <div class="layui-input-block">
            <input type="text" name="manufacturerPhone" th:field="*{manufacturerPhone}" placeholder="请输入售后公司电话" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">安装时间：</label>
        <div class="layui-input-block">
            <input type="text" name="installationTime" class="layui-input" id="installationTime" placeholder="年-月-日">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">保修时间：</label>
        <div class="layui-input-block">
            <input type="text" name="warrantyPeriod" th:field="*{warrantyPeriod}" placeholder="请输入保修时间" class="layui-input" />
        </div>
    </div>
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">主轴对应的刀具：</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="axisTool" th:field="*{axisTool}" placeholder="请输入主轴对应的刀具" class="layui-input" />-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">主轴对应的电机：</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="axisMotor" th:field="*{axisMotor}" placeholder="请输入主轴对应的电机" class="layui-input" />-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">null：</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="spare1" th:field="*{spare1}" placeholder="请输入null" class="layui-input" />-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">null：</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="spare2" th:field="*{spare2}" placeholder="请输入null" class="layui-input" />-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">null：</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="spare3" th:field="*{spare3}" placeholder="请输入null" class="layui-input" />-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">null：</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="spare4" th:field="*{spare4}" placeholder="请输入null" class="layui-input" />-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">null：</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" name="spare5" th:field="*{spare5}" placeholder="请输入null" class="layui-input" />-->
        <!--</div>-->
    <!--</div>-->
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="axis-update">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
</body>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    layui.use(['form', 'jquery','laydate','dictionary'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;

        let prefix = "/system/axis/";

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        laydate.render({
                            elem: '#startTime'
                        });
                                                                                                                                                                        laydate.render({
                            elem: '#runTime'
                        });
                                                                                                                                                                                                                                                                                                                                                                                                                                laydate.render({
                            elem: '#installationTime'
                        });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
        form.on('submit(axis-update)', function (data) {
            for(var key in data.field){
                var type=$(data.form).find("input[name='"+key+"']").attr("type");
                if(type=="checkbox"){
                    var value="";
                    $(data.form).find("input[name='"+key+"']:checked").each(function(){
                        value+=$(this).val()+",";
                    })
                    if(value!=""){
                        value=value.substr(0,value.length-1);
                        data.field[key]=value;
                    }

                }
            }
            $.ajax({
                url: prefix+'update',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'put',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                            parent.layui.table.reload("axis-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    });
</script>
</html>